//
//  FootTableViewCell.m
//  Funny
//
//  Created by dllo on 15/11/2.
//  Copyright © 2015年 King. All rights reserved.
//

#import "FootTableViewCell.h"

@implementation FootTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.headerPic = [[UIImageView alloc]init];
        [self.contentView addSubview:self.headerPic];
        self.headerPic.layer.masksToBounds = YES;
        self.headerPic.layer.borderColor = [UIColor whiteColor].CGColor;
        self.headerPic.layer.borderWidth = 2.0;
        self.headerPic.layer.cornerRadius = 25.0;
        
        self.name = [[UILabel alloc]init];
        [self.contentView addSubview:self.name];
        self.name.lineBreakMode = NSLineBreakByClipping;
        self.name.font = [UIFont systemFontOfSize:15];
        self.name.textColor = [UIColor blueColor];
        
        self.time = [[UILabel alloc]init];
        [self.contentView addSubview:self.time];
        self.name.font = [UIFont systemFontOfSize:14];
        
        self.content = [[UILabel alloc]init];
        [self.contentView addSubview:self.content];
        self.content.numberOfLines = 4;
        self.content.lineBreakMode = NSLineBreakByClipping;
        self.content.font = [UIFont systemFontOfSize:14];
        
        self.address = [[UILabel alloc]init];
        [self.contentView addSubview:self.address];
        self.address.textColor = [UIColor grayColor];
        self.address.textAlignment = NSTextAlignmentRight;
        self.address.font = [UIFont systemFontOfSize:14];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    WeakSelf(weakSelf);
    [self.headerPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView).with.offset(10);
        make.left.equalTo(weakSelf.contentView).with.offset(10);
        make.size.mas_equalTo(50);
    }];
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.contentView).with.offset(45);
        make.left.equalTo(weakSelf.contentView).with.offset(10);
        make.size.mas_equalTo(CGSizeMake(SelfWidth - 20, 100));
    }];
    self.address.frame = CGRectMake(SelfWidth - 200, 10, 190, 30);
    self.name.frame = CGRectMake(70, 10, 100, 30);
    self.time.frame = CGRectMake(SelfWidth - 100, 10, 90, 30);
}

- (void)setModel:(FootMarkModel *)model
{
    self.name.text = model.nickname;
    self.content.text = model.content;
    [self.headerPic sd_setImageWithURL:[NSURL URLWithString:model.headpic] placeholderImage:[UIImage imageNamed:@"defaultHeader.png"]];
    self.address.text = model.place;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
